// 定义函数，计算刷墙需要的油漆数目
package main

import (
	"fmt"
)

func computeAreaCount(length float64, width float64) (float64, error) {
	if length < width {
		// return -1, errors.New("length < width")
		return -1, fmt.Errorf("length %.2f < width %.2f", length, width)
	}
	return length * width / 10.0, nil
}

func printLineManyTimes(line string, times int) {
	for i := 0; i < times; i++ {
		fmt.Println(line, i)
	}
}

func main() {
	var length, width float64

	length, width = 3, 5
	res, err := computeAreaCount(length, width)
	fmt.Println(length, width, res, err)

	length, width = 3.6, 2.3
	res, err = computeAreaCount(length, width)
	fmt.Println(length, width, fmt.Sprintf("结算结果为%10.6f值", res), err)

	length, width = 6.2, 5.3
	res, err = computeAreaCount(length, width)
	fmt.Println(length, width, res, err)

	data := fmt.Sprintf("%5.2f\n", 1.0/3.0)
	fmt.Printf(data)
	fmt.Printf(data)

	printLineManyTimes("hello line", 10)
}
